#include <iostream>

using namespace std;

// 模板函数，类似Java中的泛型
template <typename T>
T add(T param1, T param2)
{
	return param1 + param2;
}

// 定义一个模板父类
template <typename T>
class CallBack{
public:
	void onError()
	{
	
	}

	void onSuccess(T t)
	{
		cout << "onSuccess: " << t << endl;
	}
};

// 子类也是模板类
template <class V>
class HTTPCallBack: public CallBack<V>{

};

int main()
{
	int ret1 = add(1, 2);
	cout << "ret1: " << ret1 << endl;

	double ret2 = add(1.0, 2.0);
	cout << "ret2: " << ret2 << endl;
	
	float ret3 = add(1.0f, 2.0f);
	cout << "ret3: " << ret3 << endl;

	HTTPCallBack<int> *callback = new HTTPCallBack<int>();
	callback->onSuccess(12);

	return 0;
}
